package com.labofjet.spring.data;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;

/**
 * 执行原生SQL用的仓库
 * 
 * @author jyzjyz12@163.com
 * 
 */
@NoRepositoryBean
@SuppressWarnings("rawtypes")
public interface NativeSQLRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {
    /**
     * 执行SQL查询,将查询结果转化成特定对象
     * 
     * @param namedQuery
     * @param paramMap
     * @param targetClass
     * @return
     */
    List executeNativeQuerySQLReturnObject(String namedQuery, Map<String, Object> paramMap, Class<?> targetClass);

    /**
     * 执行SQL查询,返回List结果
     * 
     * @param namedQuery
     * @param paramMap
     * @return
     */
    List executeNativeQuerySQLReturnList(String namedQuery, Map<String, Object> paramMap);

    /**
     * 执行SQL查询,返回Map结果
     * 
     * @param namedQuery
     * @param paramMap
     * @return
     */
    List executeNativeQuerySQLReturnMap(String namedQuery, Map<String, Object> paramMap);

    /**
     * 执行更新,删除等,返回影响行数
     * 
     * @param sql
     * @param paramMap
     */
    int executeUpdateSQL(String sql, Map<String, Object> paramMap);
}
